#include "store.h"

store::store(QWidget *parent) : QWidget(parent)
{

}

store::store(int cost, int hp, int attack, int defend)
{
    _cost=cost;
    _hp=hp;
    _attack=attack;
    _defend=defend;

    setFixedSize(500,400);
    setWindowIcon(QPixmap("://images/6.png"));
    setWindowTitle("贪婪之神");

    label=new QLabel(this);
    label->setText("点击选择想要提升的属性,将消耗"+QString::number(cost,10)+"金币");

    storeList=new QListWidget;

    storeList->addItem("血量+"+QString::number(hp,10));
    storeList->addItem("攻击+"+QString::number(attack,10));
    storeList->addItem("防御+"+QString::number(defend,10));
    storeList->addItem("退出商店");

    ConPB=new QPushButton("确定");
    ConPB->setShortcut(Qt::Key_Enter);

    QVBoxLayout *pMain=new QVBoxLayout;
    pMain->addWidget(label);
    pMain->addWidget(storeList);
    pMain->addWidget(ConPB);

    setLayout(pMain);

    connect(ConPB,SIGNAL(clicked(bool)),this,SLOT(select()));
}

void store::select()
{
    emit sendId(storeList->currentRow());
}
